{{extend './extend.art'}}
{{block 'title'}}用户登录{{/block}}
{{block 'body'}}
<body>
  <div class = "login-body">
    <div class = "login-container">
      <h4 class = "title"> 博客管理员登录</h4>
      <div class = "login">
        <form action = "/admin/login" method = "post" id = "login_form">
          <div class = "form-group">
            <label>邮件</label>
            <input name = "email" type = "email" class = "form-control" placeholder = "请输入邮件地址">
          </div>
          <div class = "form-group">
            <label>密码</label>
            <input name = "password" type = "password" class = "form-control" placeholder = "请输入密码">
          </div>
          <button type = "submit" class = "btn btn-primary">登录</button>
        </form>
      </div>
      <div class = "tips"></div>
    </div>
  </div>
  {{include './layout.art'}}
  <script>
  $('#login_form').on('submit', function () {
    // 获取表单中用户输入的内容  返回的是一个数组  数组中就存放对象 对象中就是对应的name和value   jquery中提供的一个方法
    let a = $(this).serializeArray()
    // 调用自定义的getObj方法 将数组形式转换为对象类型
    let b = getObj(a)

    // 对提交的内容进行判断
    // 如果邮箱去除两边的空格后的长度依然等于0  表示用户没有输入邮箱
    if (b.email.trim().length === 0 || b.password.trim().length === 0) {
      alert('邮箱或密码为空')
      // 阻止程序向下执行 这里一个return 会让这个函数提前结束
      return false
    }

    console.log(b)
    // 阻止表单默认提交
    // return false
  })
  </script>
</body>
{{/block}}
